package camel.first.api.datastore.internal.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.Collection;

/**
 * User: yuxinlei
 * Date: 4/13/11
 * Time: 1:51 PM
 */
@javax.persistence.Table(name = "hudsons", catalog = "reportdb")
@Entity
public class HudsonsEntity {
    private int id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private String url;

    @javax.persistence.Column(name = "url", nullable = true, insertable = true, updatable = true, length = 256, precision = 0)
    @Basic
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    private String description;

    @javax.persistence.Column(name = "description", nullable = true, insertable = true, updatable = true, length = 1024, precision = 0)
    @Basic
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    private String slaves;

    @javax.persistence.Column(name = "slaves", nullable = true, insertable = true, updatable = true, length = 512, precision = 0)
    @Basic
    public String getSlaves() {
        return slaves;
    }

    public void setSlaves(String slaves) {
        this.slaves = slaves;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        HudsonsEntity that = (HudsonsEntity) o;

        if (id != that.id) return false;
        if (description != null ? !description.equals(that.description) : that.description != null) return false;
        if (slaves != null ? !slaves.equals(that.slaves) : that.slaves != null) return false;
        if (url != null ? !url.equals(that.url) : that.url != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (url != null ? url.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (slaves != null ? slaves.hashCode() : 0);
        return result;
    }

    private Collection<ProjectsEntity> projectsesById;

    @OneToMany(mappedBy = "hudsonsByHudsonId")
    public Collection<ProjectsEntity> getProjectsesById() {
        return projectsesById;
    }

    public void setProjectsesById(Collection<ProjectsEntity> projectsesById) {
        this.projectsesById = projectsesById;
    }

    private Collection<ViewsEntity> viewsesById;

    @OneToMany(mappedBy = "hudsonsByHudsonId")
    public Collection<ViewsEntity> getViewsesById() {
        return viewsesById;
    }

    public void setViewsesById(Collection<ViewsEntity> viewsesById) {
        this.viewsesById = viewsesById;
    }
}
